The GetForeColor and GetBackColor procedures allow you to obtain the foreground and background colors for the current graphics port, both basic and color. You can use the GetCPixel procedure to determine the color of an individual pixel. The GetGray function can do more than its name implies: it can return the best gray for a given graphics device, but it can also return the best available intermediate color between any two colors.
Use the GetForeColor procedure to obtain the color of the foreground color for the current graphics port.
PROCEDURE GetForeColor (VAR color: RGBColor);
In the color parameter, the GetForeColor procedure returns the RGBColor record for the foreground color of the current graphics port. This procedure operates for graphics ports defined by both the GrafPort and CGrafPort records. If the current graphics port is defined by a CGrafPort record, the returned value is taken directly from the rgbFgColor field.
If the current graphics port is defined by a GrafPort record, then only eight possible RGB values can be returned. These eight values are determined by the values in a global variable named QDColors , which is a handle to a color table containing the current QuickDraw colors. These colors are listed in Table 4-4 . This default set of colors has been adjusted to match the colors produced on the ImageWriter II printer.
You can use the RGBForeColor procedure, described on RGBForeColor , to change the foreground color.
Use the GetBackColor procedure to obtain the background color of the current graphics port.
PROCEDURE GetBackColor (VAR color: RGBColor);
In the color parameter, the GetBackColor procedure returns the RGBColor record for the background color of the current graphics port. This procedure operates for graphics ports defined by both the GrafPort and CGrafPort records. If the current graphics port is defined by a CGrafPort record, the returned value is taken directly from the rgbBkColor field.
If the current graphics port is defined by a GrafPort record, then only eight possible colors can be returned. These eight colors are determined by the values in a global variable named QDColors , which is a handle to a color table containing the current QuickDraw colors. These colors are listed in Table 4-4 .
You can use the RGBBackColor procedure, described on RGBBackColor , to change the background color.
To determine the color of an individual pixel, use the GetCPixel procedure.
PROCEDURE GetCPixel (h,v: Integer; VAR cPix: RGBColor);
In the cPix parameter, the GetCPixel procedure returns the RGB color for the pixel at the location you specify in the h and v parameters.
You can use the SetCPixel procedure, described on SetCPixel , to change the color of this pixel.
To determine the best intermediate color between two colors on a given graphics device, use the GetGray function.
FUNCTION GetGray (device: GDHandle; backGround: RGBColor;
VAR foreGround: RGBColor): Boolean;
The GetGray function determines the midpoint values for the red, green, and blue values of the two colors you specify in the backGround and foreGround parameters. In the device parameter, supply a handle to the graphics device; in the backGround and foreGround parameters, supply RGBColor records for the two colors for which you want the best intermediate RGB color. When GetGray completes, it returns the best intermediate color in the foreGround parameter.
One use for GetGray is to return the best gray. For example, when dimming an object, supply black and white as the two colors, and GetGray returns the best available gray that lies between them. (The Menu Manager does this when dimming unavailable menu items.)
If no gray is available (or if no distinguishable third color is available), the foreGround parameter is unchanged, and the function returns FALSE . If at least one gray or intermediate color is available, it is returned in the foreGround parameter, and the function returns TRUE .